//
//  ViewController.swift
//  NingguoForum
//
//  Created by zhengsw on 2020/11/12.
//  Copyright © 2020 zhengsw. All rights reserved.
//

import UIKit

class NGHomeViewController: NGBaseViewController {

    var scrollView: NGHomeScrollView!
    var homeTableView: NGHomeTableView!
    
    var dragCriticalY: CGFloat!
    lazy var gropQueue:DispatchGroup = {
        let grop:DispatchGroup = DispatchGroup.init()
        return grop
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor(hexString: "#999999");
        
        configUI()

        
 
        HttpManager.sharedInstance.getIconNavigation(success: { (successd:Icon_navigation) in

//            self.homeTableView.setDatas(dataSource: successd)

        }) { (fail) in

        }

    }
    
    func configUI() {
        
//        navigationBarView = NGHomeNavigationBarView.init(frame: CGRect(x: 0, y: 0, width: KSCREEN_WIDTH, height: KDevice_NaviBar_Height))
//        view.addSubview(navigationBarView)
        
        navigationBarView.setBackBtnHidden(hidden: true)
        navigationBarView.setTitle(title: "宁国论坛")
        
        
        scrollView = NGHomeScrollView()
        scrollView.delegate = self
        scrollView.frame = CGRect.init(x: 0, y: KDevice_NaviBar_Height, width: KSCREEN_WIDTH, height: KSCREEN_HEIGHT - KDevice_TabBar_Height - KDevice_NaviBar_Height)
        self.view.addSubview(scrollView)
        scrollView.showsVerticalScrollIndicator = false
        scrollView.showsHorizontalScrollIndicator = false
        scrollView.bounces = false
        scrollView.isPagingEnabled = true
        
        let homeTableView = NGHomeTableView(frame: scrollView.bounds)
        homeTableView.viewController = self
        self.homeTableView = homeTableView
//        homeTableView.slideDragBlock{}
        scrollView.addSubview(homeTableView)

        let dynamicTableView = NGDynamicTableView(frame: CGRect(x: scrollView.frameW, y: 0, width: scrollView.frameW, height: scrollView.frameH))
        scrollView.addSubview(dynamicTableView)
        scrollView.contentSize = CGSize.init(width: scrollView.frameW*2, height: scrollView.frameH)
        
    }
    
    
}

extension NGHomeViewController: UIScrollViewDelegate {
     
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        print("\(scrollView.contentOffset.x)")
        let currentPosition = scrollView.contentOffset.y
//        if currentPosition >= self.dragCriticalY {
//            
//        }else {
//            
//        }
    }
}
